Imports cmplib01
Imports System.Windows.Forms
Imports System.Drawing.Drawing2D

Public Class ctlSelectedChitProperties
    Inherits System.Windows.Forms.UserControl

    Public Event ShowRuleRange(ByVal ruleio As Rule)
    Public Event ResourceSelected(ByVal res As ResourcePoolItem)
    Public Event ShowRuleDetails(ByVal ruleio As Rule)
    Public Event ShowResourceDetails(ByVal res As ResourcePoolItem)
    Public Event RedrawRequest()


#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call

    End Sub

    'UserControl overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    Friend WithEvents pnlProperties As System.Windows.Forms.Panel
    Friend WithEvents imlSecondaryTreeIcons As System.Windows.Forms.ImageList
    Friend WithEvents txtSelectedChitName As System.Windows.Forms.TextBox
    Friend WithEvents lblOrders As System.Windows.Forms.Label
    Friend WithEvents cboOrders As System.Windows.Forms.ComboBox
    Friend WithEvents lblChitDetails As System.Windows.Forms.Label
    Friend WithEvents tvwProperties As System.Windows.Forms.TreeView
    Friend WithEvents imlPropertyIcons As System.Windows.Forms.ImageList
    Friend WithEvents pnlStatistics As System.Windows.Forms.Panel
    Friend WithEvents lblStatsHeader As System.Windows.Forms.Label
    Friend WithEvents picMaxPointValue As System.Windows.Forms.PictureBox
    Friend WithEvents picCurrentPVPercent As System.Windows.Forms.PictureBox
    Friend WithEvents picSpeed As System.Windows.Forms.PictureBox
    Friend WithEvents picZOC As System.Windows.Forms.PictureBox
    Friend WithEvents mnuWaypointPopup As System.Windows.Forms.ContextMenuStrip
    Friend WithEvents mnuOrders As System.Windows.Forms.ToolStripMenuItem
    Friend WithEvents mnuSpeed As System.Windows.Forms.ToolStripMenuItem
    Friend WithEvents mnuRemoveWaypoint As System.Windows.Forms.ToolStripMenuItem
    Friend WithEvents mnuEngage As System.Windows.Forms.ToolStripMenuItem
    Friend WithEvents mnuHold As System.Windows.Forms.ToolStripMenuItem
    Friend WithEvents mnuWithdraw As System.Windows.Forms.ToolStripMenuItem
    Friend WithEvents mnuDigin As System.Windows.Forms.ToolStripMenuItem
    Friend WithEvents mnu100speed As System.Windows.Forms.ToolStripMenuItem
    Friend WithEvents mnu75speed As System.Windows.Forms.ToolStripMenuItem
    Friend WithEvents mnu50speed As System.Windows.Forms.ToolStripMenuItem
    Friend WithEvents mnu25speed As System.Windows.Forms.ToolStripMenuItem
    Friend WithEvents mnuEnterspeed As System.Windows.Forms.ToolStripMenuItem
    Friend WithEvents ToolStripMenuItem1 As System.Windows.Forms.ToolStripSeparator
    Friend WithEvents mnuRemoveAllWaypoints As System.Windows.Forms.ToolStripMenuItem
    Friend WithEvents pnlSecondary As System.Windows.Forms.Panel
    Friend WithEvents lblHeader As System.Windows.Forms.Label
    Friend WithEvents lblDescription As System.Windows.Forms.Label
    Friend WithEvents mnuResourcePopup As System.Windows.Forms.ContextMenuStrip
    Friend WithEvents mnuConsumeResource As System.Windows.Forms.ToolStripMenuItem
    Friend WithEvents mnuIndicatorPopup As System.Windows.Forms.ContextMenuStrip
    Friend WithEvents picSize As System.Windows.Forms.PictureBox
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.components = New System.ComponentModel.Container
        Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(ctlSelectedChitProperties))
        Me.pnlProperties = New System.Windows.Forms.Panel
        Me.lblDescription = New System.Windows.Forms.Label
        Me.lblStatsHeader = New System.Windows.Forms.Label
        Me.pnlStatistics = New System.Windows.Forms.Panel
        Me.picCurrentPVPercent = New System.Windows.Forms.PictureBox
        Me.picMaxPointValue = New System.Windows.Forms.PictureBox
        Me.picSpeed = New System.Windows.Forms.PictureBox
        Me.picZOC = New System.Windows.Forms.PictureBox
        Me.picSize = New System.Windows.Forms.PictureBox
        Me.lblChitDetails = New System.Windows.Forms.Label
        Me.tvwProperties = New System.Windows.Forms.TreeView
        Me.imlPropertyIcons = New System.Windows.Forms.ImageList(Me.components)
        Me.cboOrders = New System.Windows.Forms.ComboBox
        Me.lblOrders = New System.Windows.Forms.Label
        Me.txtSelectedChitName = New System.Windows.Forms.TextBox
        Me.pnlSecondary = New System.Windows.Forms.Panel
        Me.lblHeader = New System.Windows.Forms.Label
        Me.imlSecondaryTreeIcons = New System.Windows.Forms.ImageList(Me.components)
        Me.mnuWaypointPopup = New System.Windows.Forms.ContextMenuStrip(Me.components)
        Me.mnuOrders = New System.Windows.Forms.ToolStripMenuItem
        Me.mnuEngage = New System.Windows.Forms.ToolStripMenuItem
        Me.mnuHold = New System.Windows.Forms.ToolStripMenuItem
        Me.mnuWithdraw = New System.Windows.Forms.ToolStripMenuItem
        Me.mnuDigin = New System.Windows.Forms.ToolStripMenuItem
        Me.mnuSpeed = New System.Windows.Forms.ToolStripMenuItem
        Me.mnu100speed = New System.Windows.Forms.ToolStripMenuItem
        Me.mnu75speed = New System.Windows.Forms.ToolStripMenuItem
        Me.mnu50speed = New System.Windows.Forms.ToolStripMenuItem
        Me.mnu25speed = New System.Windows.Forms.ToolStripMenuItem
        Me.mnuEnterspeed = New System.Windows.Forms.ToolStripMenuItem
        Me.ToolStripMenuItem1 = New System.Windows.Forms.ToolStripSeparator
        Me.mnuRemoveWaypoint = New System.Windows.Forms.ToolStripMenuItem
        Me.mnuRemoveAllWaypoints = New System.Windows.Forms.ToolStripMenuItem
        Me.mnuResourcePopup = New System.Windows.Forms.ContextMenuStrip(Me.components)
        Me.mnuConsumeResource = New System.Windows.Forms.ToolStripMenuItem
        Me.mnuIndicatorPopup = New System.Windows.Forms.ContextMenuStrip(Me.components)
        Me.pnlProperties.SuspendLayout()
        Me.pnlStatistics.SuspendLayout()
        CType(Me.picCurrentPVPercent, System.ComponentModel.ISupportInitialize).BeginInit()
        CType(Me.picMaxPointValue, System.ComponentModel.ISupportInitialize).BeginInit()
        CType(Me.picSpeed, System.ComponentModel.ISupportInitialize).BeginInit()
        CType(Me.picZOC, System.ComponentModel.ISupportInitialize).BeginInit()
        CType(Me.picSize, System.ComponentModel.ISupportInitialize).BeginInit()
        Me.pnlSecondary.SuspendLayout()
        Me.mnuWaypointPopup.SuspendLayout()
        Me.mnuResourcePopup.SuspendLayout()
        Me.SuspendLayout()
        '
        'pnlProperties
        '
        Me.pnlProperties.BackColor = System.Drawing.Color.Black
        Me.pnlProperties.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.pnlProperties.Controls.Add(Me.lblDescription)
        Me.pnlProperties.Controls.Add(Me.lblStatsHeader)
        Me.pnlProperties.Controls.Add(Me.pnlStatistics)
        Me.pnlProperties.Controls.Add(Me.lblChitDetails)
        Me.pnlProperties.Controls.Add(Me.tvwProperties)
        Me.pnlProperties.Controls.Add(Me.cboOrders)
        Me.pnlProperties.Controls.Add(Me.lblOrders)
        Me.pnlProperties.Controls.Add(Me.txtSelectedChitName)
        Me.pnlProperties.Controls.Add(Me.pnlSecondary)
        Me.pnlProperties.Dock = System.Windows.Forms.DockStyle.Fill
        Me.pnlProperties.Location = New System.Drawing.Point(0, 0)
        Me.pnlProperties.Name = "pnlProperties"
        Me.pnlProperties.Size = New System.Drawing.Size(210, 450)
        Me.pnlProperties.TabIndex = 14
        '
        'lblDescription
        '
        Me.lblDescription.Anchor = CType(((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Left) _
                    Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.lblDescription.BackColor = System.Drawing.Color.Gainsboro
        Me.lblDescription.Location = New System.Drawing.Point(7, 397)
        Me.lblDescription.Name = "lblDescription"
        Me.lblDescription.Size = New System.Drawing.Size(200, 50)
        Me.lblDescription.TabIndex = 44
        Me.lblDescription.Text = "No description"
        '
        'lblStatsHeader
        '
        Me.lblStatsHeader.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left) _
                    Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.lblStatsHeader.BackColor = System.Drawing.Color.DarkSeaGreen
        Me.lblStatsHeader.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.lblStatsHeader.Font = New System.Drawing.Font("Cambria", 9.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.lblStatsHeader.ForeColor = System.Drawing.Color.Black
        Me.lblStatsHeader.Location = New System.Drawing.Point(3, 49)
        Me.lblStatsHeader.Name = "lblStatsHeader"
        Me.lblStatsHeader.Size = New System.Drawing.Size(208, 18)
        Me.lblStatsHeader.TabIndex = 24
        Me.lblStatsHeader.Text = "Statistics"
        Me.lblStatsHeader.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
        '
        'pnlStatistics
        '
        Me.pnlStatistics.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left) _
                    Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.pnlStatistics.BackColor = System.Drawing.Color.PowderBlue
        Me.pnlStatistics.Controls.Add(Me.picCurrentPVPercent)
        Me.pnlStatistics.Controls.Add(Me.picMaxPointValue)
        Me.pnlStatistics.Controls.Add(Me.picSpeed)
        Me.pnlStatistics.Controls.Add(Me.picZOC)
        Me.pnlStatistics.Controls.Add(Me.picSize)
        Me.pnlStatistics.Location = New System.Drawing.Point(7, 66)
        Me.pnlStatistics.Name = "pnlStatistics"
        Me.pnlStatistics.Size = New System.Drawing.Size(204, 97)
        Me.pnlStatistics.TabIndex = 43
        '
        'picCurrentPVPercent
        '
        Me.picCurrentPVPercent.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left) _
                    Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.picCurrentPVPercent.BackColor = System.Drawing.Color.Gray
        Me.picCurrentPVPercent.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.picCurrentPVPercent.Location = New System.Drawing.Point(6, 74)
        Me.picCurrentPVPercent.Name = "picCurrentPVPercent"
        Me.picCurrentPVPercent.Size = New System.Drawing.Size(187, 18)
        Me.picCurrentPVPercent.TabIndex = 4
        Me.picCurrentPVPercent.TabStop = False
        '
        'picMaxPointValue
        '
        Me.picMaxPointValue.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left) _
                    Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.picMaxPointValue.BackColor = System.Drawing.Color.Gray
        Me.picMaxPointValue.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.picMaxPointValue.Location = New System.Drawing.Point(6, 57)
        Me.picMaxPointValue.Name = "picMaxPointValue"
        Me.picMaxPointValue.Size = New System.Drawing.Size(187, 18)
        Me.picMaxPointValue.TabIndex = 3
        Me.picMaxPointValue.TabStop = False
        '
        'picSpeed
        '
        Me.picSpeed.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left) _
                    Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.picSpeed.BackColor = System.Drawing.Color.Gray
        Me.picSpeed.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.picSpeed.Location = New System.Drawing.Point(6, 40)
        Me.picSpeed.Name = "picSpeed"
        Me.picSpeed.Size = New System.Drawing.Size(187, 18)
        Me.picSpeed.TabIndex = 2
        Me.picSpeed.TabStop = False
        '
        'picZOC
        '
        Me.picZOC.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left) _
                    Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.picZOC.BackColor = System.Drawing.Color.Gray
        Me.picZOC.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.picZOC.Location = New System.Drawing.Point(6, 23)
        Me.picZOC.Name = "picZOC"
        Me.picZOC.Size = New System.Drawing.Size(187, 18)
        Me.picZOC.TabIndex = 1
        Me.picZOC.TabStop = False
        '
        'picSize
        '
        Me.picSize.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left) _
                    Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.picSize.BackColor = System.Drawing.Color.Gray
        Me.picSize.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.picSize.Location = New System.Drawing.Point(6, 6)
        Me.picSize.Name = "picSize"
        Me.picSize.Size = New System.Drawing.Size(187, 18)
        Me.picSize.TabIndex = 0
        Me.picSize.TabStop = False
        '
        'lblChitDetails
        '
        Me.lblChitDetails.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left) _
                    Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.lblChitDetails.BackColor = System.Drawing.Color.DarkSeaGreen
        Me.lblChitDetails.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.lblChitDetails.Font = New System.Drawing.Font("Cambria", 9.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.lblChitDetails.ForeColor = System.Drawing.Color.Black
        Me.lblChitDetails.Location = New System.Drawing.Point(3, 206)
        Me.lblChitDetails.Name = "lblChitDetails"
        Me.lblChitDetails.Size = New System.Drawing.Size(208, 17)
        Me.lblChitDetails.TabIndex = 23
        Me.lblChitDetails.Text = "Details"
        Me.lblChitDetails.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
        '
        'tvwProperties
        '
        Me.tvwProperties.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _
                    Or System.Windows.Forms.AnchorStyles.Left) _
                    Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.tvwProperties.BorderStyle = System.Windows.Forms.BorderStyle.None
        Me.tvwProperties.Font = New System.Drawing.Font("Cambria", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.tvwProperties.ImageIndex = 0
        Me.tvwProperties.ImageList = Me.imlPropertyIcons
        Me.tvwProperties.Location = New System.Drawing.Point(7, 223)
        Me.tvwProperties.Name = "tvwProperties"
        Me.tvwProperties.SelectedImageIndex = 0
        Me.tvwProperties.Size = New System.Drawing.Size(200, 171)
        Me.tvwProperties.TabIndex = 27
        '
        'imlPropertyIcons
        '
        Me.imlPropertyIcons.ImageStream = CType(resources.GetObject("imlPropertyIcons.ImageStream"), System.Windows.Forms.ImageListStreamer)
        Me.imlPropertyIcons.TransparentColor = System.Drawing.Color.Transparent
        Me.imlPropertyIcons.Images.SetKeyName(0, "")
        Me.imlPropertyIcons.Images.SetKeyName(1, "")
        Me.imlPropertyIcons.Images.SetKeyName(2, "")
        Me.imlPropertyIcons.Images.SetKeyName(3, "")
        Me.imlPropertyIcons.Images.SetKeyName(4, "")
        Me.imlPropertyIcons.Images.SetKeyName(5, "")
        Me.imlPropertyIcons.Images.SetKeyName(6, "")
        Me.imlPropertyIcons.Images.SetKeyName(7, "")
        Me.imlPropertyIcons.Images.SetKeyName(8, "")
        Me.imlPropertyIcons.Images.SetKeyName(9, "")
        Me.imlPropertyIcons.Images.SetKeyName(10, "")
        Me.imlPropertyIcons.Images.SetKeyName(11, "")
        Me.imlPropertyIcons.Images.SetKeyName(12, "")
        Me.imlPropertyIcons.Images.SetKeyName(13, "")
        Me.imlPropertyIcons.Images.SetKeyName(14, "")
        Me.imlPropertyIcons.Images.SetKeyName(15, "")
        Me.imlPropertyIcons.Images.SetKeyName(16, "")
        Me.imlPropertyIcons.Images.SetKeyName(17, "")
        Me.imlPropertyIcons.Images.SetKeyName(18, "")
        Me.imlPropertyIcons.Images.SetKeyName(19, "resource.bmp")
        Me.imlPropertyIcons.Images.SetKeyName(20, "icon-3.bmp")
        Me.imlPropertyIcons.Images.SetKeyName(21, "range.bmp")
        Me.imlPropertyIcons.Images.SetKeyName(22, "usesresource.bmp")
        Me.imlPropertyIcons.Images.SetKeyName(23, "SwitchDevice.ico")
        Me.imlPropertyIcons.Images.SetKeyName(24, "Attribute.bmp")
        Me.imlPropertyIcons.Images.SetKeyName(25, "Order.ico")
        '
        'cboOrders
        '
        Me.cboOrders.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left) _
                    Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.cboOrders.FlatStyle = System.Windows.Forms.FlatStyle.Flat
        Me.cboOrders.Font = New System.Drawing.Font("Cambria", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.cboOrders.Items.AddRange(New Object() {"Hold", "Withdraw", "Engage"})
        Me.cboOrders.Location = New System.Drawing.Point(7, 183)
        Me.cboOrders.Name = "cboOrders"
        Me.cboOrders.Size = New System.Drawing.Size(201, 20)
        Me.cboOrders.TabIndex = 21
        Me.cboOrders.Text = "<None>"
        '
        'lblOrders
        '
        Me.lblOrders.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left) _
                    Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.lblOrders.BackColor = System.Drawing.Color.DarkSeaGreen
        Me.lblOrders.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.lblOrders.Font = New System.Drawing.Font("Cambria", 9.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.lblOrders.ForeColor = System.Drawing.Color.Black
        Me.lblOrders.Location = New System.Drawing.Point(3, 166)
        Me.lblOrders.Name = "lblOrders"
        Me.lblOrders.Size = New System.Drawing.Size(208, 17)
        Me.lblOrders.TabIndex = 20
        Me.lblOrders.Text = "Current Orders"
        Me.lblOrders.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
        '
        'txtSelectedChitName
        '
        Me.txtSelectedChitName.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left) _
                    Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.txtSelectedChitName.BorderStyle = System.Windows.Forms.BorderStyle.None
        Me.txtSelectedChitName.Font = New System.Drawing.Font("Cambria", 11.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(204, Byte))
        Me.txtSelectedChitName.Location = New System.Drawing.Point(8, 28)
        Me.txtSelectedChitName.Name = "txtSelectedChitName"
        Me.txtSelectedChitName.Size = New System.Drawing.Size(203, 18)
        Me.txtSelectedChitName.TabIndex = 19
        Me.txtSelectedChitName.Text = "<Selected Chit Name>"
        '
        'pnlSecondary
        '
        Me.pnlSecondary.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left) _
                    Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.pnlSecondary.BackColor = System.Drawing.Color.SteelBlue
        Me.pnlSecondary.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.pnlSecondary.Controls.Add(Me.lblHeader)
        Me.pnlSecondary.Location = New System.Drawing.Point(2, -1)
        Me.pnlSecondary.Name = "pnlSecondary"
        Me.pnlSecondary.Size = New System.Drawing.Size(208, 29)
        Me.pnlSecondary.TabIndex = 10
        '
        'lblHeader
        '
        Me.lblHeader.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left) _
                    Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.lblHeader.AutoSize = True
        Me.lblHeader.Font = New System.Drawing.Font("Cambria", 14.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.lblHeader.Location = New System.Drawing.Point(34, 3)
        Me.lblHeader.Name = "lblHeader"
        Me.lblHeader.Size = New System.Drawing.Size(122, 22)
        Me.lblHeader.TabIndex = 0
        Me.lblHeader.Text = "Selected Chit"
        Me.lblHeader.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
        '
        'imlSecondaryTreeIcons
        '
        Me.imlSecondaryTreeIcons.ImageStream = CType(resources.GetObject("imlSecondaryTreeIcons.ImageStream"), System.Windows.Forms.ImageListStreamer)
        Me.imlSecondaryTreeIcons.TransparentColor = System.Drawing.Color.Transparent
        Me.imlSecondaryTreeIcons.Images.SetKeyName(0, "")
        Me.imlSecondaryTreeIcons.Images.SetKeyName(1, "")
        Me.imlSecondaryTreeIcons.Images.SetKeyName(2, "")
        Me.imlSecondaryTreeIcons.Images.SetKeyName(3, "")
        Me.imlSecondaryTreeIcons.Images.SetKeyName(4, "")
        Me.imlSecondaryTreeIcons.Images.SetKeyName(5, "")
        Me.imlSecondaryTreeIcons.Images.SetKeyName(6, "battlegroupicon.bmp")
        Me.imlSecondaryTreeIcons.Images.SetKeyName(7, "uniticon.bmp")
        '
        'mnuWaypointPopup
        '
        Me.mnuWaypointPopup.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.mnuOrders, Me.mnuSpeed, Me.ToolStripMenuItem1, Me.mnuRemoveWaypoint, Me.mnuRemoveAllWaypoints})
        Me.mnuWaypointPopup.Name = "mnuWaypointPopup"
        Me.mnuWaypointPopup.Size = New System.Drawing.Size(193, 98)
        '
        'mnuOrders
        '
        Me.mnuOrders.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text
        Me.mnuOrders.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.mnuEngage, Me.mnuHold, Me.mnuWithdraw, Me.mnuDigin})
        Me.mnuOrders.Name = "mnuOrders"
        Me.mnuOrders.Size = New System.Drawing.Size(192, 22)
        Me.mnuOrders.Text = "Orders"
        '
        'mnuEngage
        '
        Me.mnuEngage.Name = "mnuEngage"
        Me.mnuEngage.Size = New System.Drawing.Size(131, 22)
        Me.mnuEngage.Text = "Engage"
        '
        'mnuHold
        '
        Me.mnuHold.Name = "mnuHold"
        Me.mnuHold.Size = New System.Drawing.Size(131, 22)
        Me.mnuHold.Text = "Hold"
        '
        'mnuWithdraw
        '
        Me.mnuWithdraw.Name = "mnuWithdraw"
        Me.mnuWithdraw.Size = New System.Drawing.Size(131, 22)
        Me.mnuWithdraw.Text = "Withdraw"
        '
        'mnuDigin
        '
        Me.mnuDigin.Name = "mnuDigin"
        Me.mnuDigin.Size = New System.Drawing.Size(131, 22)
        Me.mnuDigin.Text = "Dig-in"
        Me.mnuDigin.Visible = False
        '
        'mnuSpeed
        '
        Me.mnuSpeed.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text
        Me.mnuSpeed.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.mnu100speed, Me.mnu75speed, Me.mnu50speed, Me.mnu25speed, Me.mnuEnterspeed})
        Me.mnuSpeed.Name = "mnuSpeed"
        Me.mnuSpeed.Size = New System.Drawing.Size(192, 22)
        Me.mnuSpeed.Text = "Speed"
        '
        'mnu100speed
        '
        Me.mnu100speed.Name = "mnu100speed"
        Me.mnu100speed.Size = New System.Drawing.Size(144, 22)
        Me.mnu100speed.Text = "100%"
        '
        'mnu75speed
        '
        Me.mnu75speed.Name = "mnu75speed"
        Me.mnu75speed.Size = New System.Drawing.Size(144, 22)
        Me.mnu75speed.Text = "75%"
        '
        'mnu50speed
        '
        Me.mnu50speed.Name = "mnu50speed"
        Me.mnu50speed.Size = New System.Drawing.Size(144, 22)
        Me.mnu50speed.Text = "50%"
        '
        'mnu25speed
        '
        Me.mnu25speed.Name = "mnu25speed"
        Me.mnu25speed.Size = New System.Drawing.Size(144, 22)
        Me.mnu25speed.Text = "25%"
        '
        'mnuEnterspeed
        '
        Me.mnuEnterspeed.Name = "mnuEnterspeed"
        Me.mnuEnterspeed.Size = New System.Drawing.Size(144, 22)
        Me.mnuEnterspeed.Text = "Enter Speed"
        '
        'ToolStripMenuItem1
        '
        Me.ToolStripMenuItem1.Name = "ToolStripMenuItem1"
        Me.ToolStripMenuItem1.Size = New System.Drawing.Size(189, 6)
        '
        'mnuRemoveWaypoint
        '
        Me.mnuRemoveWaypoint.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text
        Me.mnuRemoveWaypoint.Name = "mnuRemoveWaypoint"
        Me.mnuRemoveWaypoint.Size = New System.Drawing.Size(192, 22)
        Me.mnuRemoveWaypoint.Text = "Remove Waypoint"
        '
        'mnuRemoveAllWaypoints
        '
        Me.mnuRemoveAllWaypoints.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text
        Me.mnuRemoveAllWaypoints.Name = "mnuRemoveAllWaypoints"
        Me.mnuRemoveAllWaypoints.Size = New System.Drawing.Size(192, 22)
        Me.mnuRemoveAllWaypoints.Text = "Remove All Waypoints"
        '
        'mnuResourcePopup
        '
        Me.mnuResourcePopup.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.mnuConsumeResource})
        Me.mnuResourcePopup.Name = "mnuResourcePopup"
        Me.mnuResourcePopup.Size = New System.Drawing.Size(178, 26)
        '
        'mnuConsumeResource
        '
        Me.mnuConsumeResource.Image = CType(resources.GetObject("mnuConsumeResource.Image"), System.Drawing.Image)
        Me.mnuConsumeResource.ImageTransparentColor = System.Drawing.Color.White
        Me.mnuConsumeResource.Name = "mnuConsumeResource"
        Me.mnuConsumeResource.Size = New System.Drawing.Size(177, 22)
        Me.mnuConsumeResource.Text = "Consume Resource"
        '
        'mnuIndicatorPopup
        '
        Me.mnuIndicatorPopup.Name = "mnuIndicatorPopup"
        Me.mnuIndicatorPopup.Size = New System.Drawing.Size(153, 26)
        '
        'ctlSelectedChitProperties
        '
        Me.BackColor = System.Drawing.Color.LightSkyBlue
        Me.Controls.Add(Me.pnlProperties)
        Me.Name = "ctlSelectedChitProperties"
        Me.Size = New System.Drawing.Size(210, 450)
        Me.pnlProperties.ResumeLayout(False)
        Me.pnlProperties.PerformLayout()
        Me.pnlStatistics.ResumeLayout(False)
        CType(Me.picCurrentPVPercent, System.ComponentModel.ISupportInitialize).EndInit()
        CType(Me.picMaxPointValue, System.ComponentModel.ISupportInitialize).EndInit()
        CType(Me.picSpeed, System.ComponentModel.ISupportInitialize).EndInit()
        CType(Me.picZOC, System.ComponentModel.ISupportInitialize).EndInit()
        CType(Me.picSize, System.ComponentModel.ISupportInitialize).EndInit()
        Me.pnlSecondary.ResumeLayout(False)
        Me.pnlSecondary.PerformLayout()
        Me.mnuWaypointPopup.ResumeLayout(False)
        Me.mnuResourcePopup.ResumeLayout(False)
        Me.ResumeLayout(False)

    End Sub

#End Region

    Private ptrCurrentGame As CampaignerGameData
    Private ptrSelectedChit As ChitMember

    Private _mapdata As FMPLib01.FlexMapData
    Private unitReadOnly As Boolean
    Private populatingOrdersList As Boolean
    Private BiggestSize As Single
    Private FastestSpeed As Single
    Private BiggestZOC As Single
    Private HighestMaxPV As Integer

    Private firstWaypointNode As CampaignerItemTreeNode

    Private m_PixelsPerOneMile As Single

    Public Property GameData() As CampaignerGameData
        Get
            Return ptrCurrentGame
        End Get
        Set(ByVal Value As CampaignerGameData)
            ptrCurrentGame = Value
        End Set
    End Property

    Public WriteOnly Property MapData() As FMPLib01.FlexMapData
        Set(ByVal value As FMPLib01.FlexMapData)
            _mapdata = value
        End Set
    End Property

    Public Sub PopulateStatisticBenchmarks()
        '// populates the BiggestLOS, Fastest Speed, biggest ZOC
        '// we can also use PV Max and current PV?

        '// reset!
        BiggestSize = 0
        FastestSpeed = 0
        BiggestZOC = 0
        HighestMaxPV = 0

        Try

            For Each mem As ChitMember In ptrCurrentGame.Chits
                If mem.Size > BiggestSize Then BiggestSize = mem.Size
                If mem.ZOC > BiggestZOC Then BiggestZOC = mem.ZOC

                If mem.UnitType = GroundChitClass_cgd.Battlegroup Then
                    If DirectCast(mem, BattlegroupChit).movementSpeed > FastestSpeed Then FastestSpeed = DirectCast(mem, BattlegroupChit).movementSpeed
                    If DirectCast(mem, BattlegroupChit).deployedpointvalue > HighestMaxPV Then HighestMaxPV = DirectCast(mem, BattlegroupChit).deployedpointvalue
                End If
            Next


        Catch ex As Exception
            HandleException(Me.Name, ex)
        End Try

        If BiggestSize > 1000 Then BiggestSize = 1000

    End Sub

    Public Property PixelsPerOneMile() As Single
        Get
            Return m_PixelsPerOneMile
        End Get
        Set(ByVal Value As Single)
            m_PixelsPerOneMile = Value
        End Set
    End Property

    Public Sub ClearSelectedList(Optional ByVal ChitNameText As String = "<none>")
        Try
            ' clears the list of all data 
            txtSelectedChitName.Text = ChitNameText
            tvwProperties.Nodes.Clear()
            '            tvwSecondary.Nodes.Clear()
            cboOrders.Text = "<none>"

            '// clear each bar
            ClearBar(Me.picSize, "Size")
            ClearBar(Me.picZOC, "Zone Of Control")
            ClearBar(Me.picMaxPointValue, "Maximum PV")
            ClearBar(Me.picCurrentPVPercent, "Current PV")
            ClearBar(Me.picSpeed, "Movement Speed")

            lbldescription.Text = "No description"
        Catch ex As Exception
            HandleException(c_Module, ex)
        End Try

    End Sub

    Private Sub drawBar(ByVal strength As Single, ByVal target As PictureBox, ByVal text As String)
        Dim bar As New RectangleF(1, 1, (picSize.Width * strength) - 6, 14)
        Dim imCom As Image = New Bitmap(target.Width, target.Height)
        Dim g As Graphics = Graphics.FromImage(imCom)

        Try
            Dim br As New LinearGradientBrush(bar, Color.Red, Color.Green, LinearGradientMode.Horizontal)

            g.FillRectangle(br, bar)

            g.DrawString(text, Me.Font, New SolidBrush(Color.Yellow), 2, 2)

            target.Image = imCom

        Catch ex As Exception

        End Try
        g.Dispose()

    End Sub

    Private Sub ClearBar(ByVal target As PictureBox, ByVal text As String)
        ' clears the bar to make it gray and puts in subdued text.
        Dim bar As New RectangleF(1, 1, (picSize.Width) - 6, 14)
        Dim imCom As Image = New Bitmap(target.Width, target.Height)
        Dim g As Graphics = Graphics.FromImage(imCom)
        Dim br As New SolidBrush(target.BackColor)

        Try
            g.FillRectangle(br, bar)
            g.DrawString(text, Me.Font, New SolidBrush(Color.DarkGray), 2, 2)
            target.Image = imCom
        Catch ex As Exception

        End Try
        g.Dispose()

    End Sub

    Public Sub ShowSelectedChitProperties(ByRef selectedChit As ChitMember, ByRef GameData As CampaignerGameData, Optional ByVal ReadonlyUnit As Boolean = True)
        Try

            firstWaypointNode = Nothing '// this is used to keep current with the orders box

            If selectedChit Is Nothing Then
                ClearSelectedList("<none>")
                Exit Sub
            End If

            ptrCurrentGame = GameData
            ptrSelectedChit = selectedChit

            unitReadOnly = ReadonlyUnit

            ' populate the base properties that all chits share
            PopulateBaseProperties()
            If ptrSelectedChit.UnitType = GroundChitClass_cgd.Objective Then Populate(DirectCast(ptrSelectedChit, InstallationChit))
            If ptrSelectedChit.UnitType = GroundChitClass_cgd.Battlegroup Then Populate(DirectCast(ptrSelectedChit, BattlegroupChit))

        Catch ex As Exception
            HandleException(c_Module, ex)
        End Try
    End Sub

    Private Sub Populate(ByRef inst As InstallationChit)
        ' when viewing an objective, tvwsecondary is used to display rules and resources
        ' clear the secondary view
        Try
            ' clear the other statistics
            ClearBar(picSpeed, "Movement Speed")
            ClearBar(picMaxPointValue, "Maximum PV")
            ClearBar(picCurrentPVPercent, "PV Percent")

            cboOrders.Enabled = False
            cboOrders.Text = "<N/A>"   '// not sure why we should even SHOW an orders dropdown for installations.

            tvwProperties.Nodes.Add("Status: " & inst.Status)

            If Not inst.chitRules Is Nothing Then
                For Each ru As Rule In inst.chitRules
                    tvwProperties.Nodes.Add(CreateRuleNode(ru))
                Next ru
            End If

            '// resources
            For Each resPool As ResourcePoolItem In inst.Resources
                tvwProperties.Nodes.Add(CreateResourceNode(resPool))
            Next
        Catch ex As Exception
            HandleException(c_Module, ex)
        End Try
    End Sub

    Private Function CreateRuleNode(ByRef rul As Rule) As CampaignerItemTreeNode
        Try
            Dim ruleNode As New CampaignerItemTreeNode
            ruleNode.Item = rul
            ruleNode.ItemType = CampaignerItem_cgd.Rule
            Dim usesText As String

            If rul.Active = False Then
                ruleNode.ForeColor = Color.DarkRed
            Else
                ruleNode.ForeColor = Color.Black
            End If

            ruleNode.Text = rul.ptrRule.RuleName & " [" & rul.usesRemaining & "]"
            ruleNode.Tag = rul
            ruleNode.ImageIndex = 18
            ruleNode.SelectedImageIndex = 18

            '// don't forget, active/inactive
            Dim activeNode As New TreeNode()
            If rul.Active Then
                activeNode.Text = "Active"
            Else
                activeNode.Text = "Inactive"
            End If
            activeNode.ImageIndex = 23
            activeNode.SelectedImageIndex = 23
            ruleNode.Nodes.Add(activeNode)

            If rul.ptrRule.MaxUses = 0 Then
                usesText = "unlimited"
            Else
                usesText = rul.usesRemaining
            End If

            Dim availnode, rangenode As New TreeNode
            availnode.Text = "Available uses: " & usesText
            availnode.ImageIndex = 20
            availnode.SelectedImageIndex = 20

            rangenode.Text = "Range: " & rul.ptrRule.BasicRange
            rangenode.ImageIndex = 21
            rangenode.SelectedImageIndex = 21
            ruleNode.Nodes.Add(availnode)
            RuleNode.Nodes.Add(rangenode)

            '// if the rule consumes resources:
            If TypeOf rul.ptrRule Is ResourceConsumingRuleType Then
                Dim resrule As ResourceConsumingRuleType = rul.ptrRule
                Dim cost As ResourceCost
                For Each cost In resrule.Costs
                    Dim resusenode As New TreeNode("Uses " & cost.ResourceCost & " " & cost.ResourceTypeName)
                    resusenode.ImageIndex = 22
                    resusenode.SelectedImageIndex = 22
                    ruleNode.Nodes.Add(resusenode)
                Next
            End If

            Return ruleNode

        Catch ex As Exception
            Dim errnode As New CampaignerItemTreeNode
            errnode.Text = "error"
            Return errnode
        End Try
    End Function

    Private Function CreateResourceNode(ByVal respool As ResourcePoolItem) As CampaignerItemTreeNode
        Try
            Dim resNode As New CampaignerItemTreeNode
            resNode.ItemType = CampaignerItem_cgd.Resource
            resNode.Item = respool

            resNode.Text = resPool.resourceTypeptr.ResourceName & " [" & resPool.localAmount & "/" & resPool.maxAmount & "] + " & resPool.accrueAmount
            resNode.Tag = resPool
            resNode.SelectedImageIndex = 19
            resNode.ImageIndex = 19

            Return resNode

        Catch ex As Exception
            Dim errnode As New CampaignerItemTreeNode
            errnode.Text = "error"
            Return errnode
        End Try
    End Function

    Private Sub Populate(ByRef batt As BattlegroupChit)

        Try
            batt.calculateProperties()

            ' orders
            cboOrders.Text = batt.order
            cboOrders.Enabled = True

            '// statistics
            Try
                Dim statStrength As Single
                statStrength = batt.movementSpeed / FastestSpeed
                drawBar(statStrength, picSpeed, "Movement Speed")
                statStrength = batt.deployedpointvalue / HighestMaxPV
                drawBar(statStrength, picMaxPointValue, "Maximum PV")
                statStrength = batt.CurrentPV / batt.deployedpointvalue
                drawBar(statStrength, picCurrentPVPercent, "Current PV %")

            Catch ex As Exception
                HandleException(c_Module, ex)
            End Try

            ' set up the additional information for units
            Dim newNode As New TreeNode
            newNode.Text = "Movement: " & batt.movementSpeed
            newNode.ImageIndex = 5
            newNode.SelectedImageIndex = 5
            tvwProperties.Nodes.Add(newNode)

            newNode = New TreeNode
            '// if we use override point value, show that value, if not, use suggested.
            If batt.overridePointValue > 0 Then
                newNode.Text = "Point Value: " & batt.overridePointValue & " [" & batt.deployedpointvalue & "] override"
            Else
                newNode.Text = "Point Value: " & batt.SuggestedPointValue & " [" & batt.deployedpointvalue & "]"
            End If
            newNode.ImageIndex = 6
            newNode.SelectedImageIndex = 6
            tvwProperties.Nodes.Add(newNode)

            newNode = New TreeNode
            newNode.Text = "Reinforcement Range: " & batt.effectiveReinforcement
            newNode.ImageIndex = 14
            newNode.SelectedImageIndex = 14
            tvwProperties.Nodes.Add(newNode)

            newNode = New TreeNode
            newNode.Text = "Status: " & batt.Status.ToString
            newNode.ImageIndex = 7
            newNode.SelectedImageIndex = 7
            tvwProperties.Nodes.Add(newNode)

            newNode = New TreeNode
            newNode.Text = "Waypoint Length: " & WayLength(ptrSelectedChit)
            newNode.ImageIndex = 16
            newNode.SelectedImageIndex = 16
            '// put each waypoint in here! Yah!
            Dim i As Integer = 1

            For Each swayp As SmartWaypoint In batt.waypoints
                Dim wapNode As New CampaignerItemTreeNode()

                '// for current orders, to keep them matching
                If i = 1 Then firstWaypointNode = wapNode

                wapNode.Tag = i
                wapNode.ItemType = CampaignerItem_cgd.waypoint
                wapNode.Item = swayp
                wapNode.Text = "[" & wapNode.Tag & "] " & WaypointText(swayp)
                wapNode.SelectedImageIndex = 17
                wapNode.ImageIndex = 17
                newNode.Nodes.Add(wapNode)
                i += 1
            Next

            tvwProperties.Nodes.Add(newNode)

            tvwProperties.Nodes.Add(BGNode(batt))
        Catch ex As Exception
            HandleException(c_Module, ex)
        End Try

    End Sub

    Private Function WaypointText(ByRef swap As SmartWaypoint) As String
        Try
            Dim mphMPD As String = " mph"
            If ptrCurrentGame.TurnLength >= TurnLength_cgd.FullDay Then mphMPD = " mpd"
            Return swap.OrderText & " (" & swap.Speed & mphMPD & ")"
        Catch ex As Exception
            Return "Error in text."
        End Try
    End Function

    Private Function BGNode(ByRef bg As BattlegroupChit) As TreeNode
        Try
            Dim nod As New TreeNode
            nod.Text = bg.Name
            nod.SelectedImageIndex = 12
            nod.ImageIndex = 12
            For Each mem As ChitMember In bg.members
                If mem.UnitType = GroundChitClass_cgd.Battlegroup Then
                    nod.Nodes.Add(BGNode(mem))
                Else
                    Dim unNode As New CampaignerItemTreeNode()
                    unNode.Text = mem.Name
                    unNode.ItemType = CampaignerItem_cgd.Unit
                    unNode.Item = mem

                    unNode.ImageIndex = 13
                    unNode.SelectedImageIndex = 13
                    If mem.Status = GroundUnitStatus_cgd.Dead Then
                        unNode.ForeColor = Color.DarkRed
                        '// give it a skully
                        unNode.SelectedImageIndex = 15
                        unNode.ImageIndex = 15
                    End If

                    If mem.UnitType = GroundChitClass_cgd.Unit Then
                        Dim un As ChitUnitTypeMember = mem

                        If un.Attributes Is Nothing Then un.Attributes = New Collection

                        '// attributes
                        For Each a As String In un.Attributes
                            Dim anode As New TreeNode(a)
                            anode.SelectedImageIndex = 24
                            anode.ImageIndex = 24
                            unNode.Nodes.Add(anode)
                        Next

                        '// elements
                        For Each e As GroupableElement In un.elements
                            Dim elenode As New TreeNode("[" & e.Count & "] " & e.ElementTypeName)
                            elenode.ImageIndex = 10
                            elenode.SelectedImageIndex = 10
                            unNode.Nodes.Add(elenode)
                        Next

                        '// indies!
                        '// dang. There's a lot of stuff!!
                        If un.Indicators Is Nothing Then un.Indicators = New Collection
                        For Each iin As IIndicatorEntry In un.Indicators
                            Dim indiNode As New CampaignerItemTreeNode '= iin.CITreenode
                            indiNode.Text = iin.displayText
                            indiNode.ItemType = CampaignerItem_cgd.Indicator
                            indiNode.Item = iin
                            indiNode.ImageIndex = 25
                            indiNode.SelectedImageIndex = 25
                            unNode.Nodes.Add(indiNode)
                        Next

                        '// if there are rules for this unit: 
                        For Each rul As Rule In mem.chitRules
                            unNode.Nodes.Add(CreateRuleNode(rul))
                        Next

                    End If
                    nod.Nodes.Add(unNode)
                End If
            Next

            Return nod

        Catch ex As Exception
            HandleException(c_Module, ex)
            Return New TreeNode("Error")
        End Try
    End Function

    Public ReadOnly Property SelectedChit() As ChitMember
        Get
            Return ptrSelectedChit
        End Get
    End Property

    Private Sub PopulateBaseProperties()
        ' clear the treeview
        Try
            Dim node As New TreeNode

            tvwProperties.Nodes.Clear()


            '// don't show enemy chit details
            If Not ptrCurrentGame.selectedPlayer.PlayerName = "<Moderator>" Then
                If Not ptrSelectedChit.OwningFaction.Equals(ptrCurrentGame.selectedFaction) Then
                    ptrSelectedChit = Nothing
                    Exit Sub
                End If

            End If
            
            txtSelectedChitName.Text = ptrSelectedChit.Name


            '// iffin its a battlegroup, calculate properties
            If ptrSelectedChit.UnitType = GroundChitClass_cgd.Battlegroup Then
                DirectCast(ptrSelectedChit, BattlegroupChit).calculateProperties()
            End If


            ' statistics common to installations and units
            Dim StatStrength As Single
            StatStrength = ptrSelectedChit.Size / BiggestSize
            If StatStrength > 1 Then StatStrength = 1 ' this occurs when a titanic object is on the field.
            drawBar(StatStrength, picSize, "Size")
            StatStrength = ptrSelectedChit.ZOC / BiggestZOC
            drawBar(StatStrength, picZOC, "Zone Of Control")

            lblDescription.Text = "No description"

            With tvwProperties.Nodes
                'TASK: modify to show miles and other useful info
                node.Text = "LOS: " & ptrSelectedChit.LOS
                node.ImageIndex = 0
                node.SelectedImageIndex = 0
                .Add(node)

                node = New TreeNode
                node.Text = "LOS Power: " & ptrCurrentGame.TextForLOSPower(ptrSelectedChit.LOSPower)
                node.ImageIndex = 1
                node.SelectedImageIndex = 1
                .Add(node)

                node = New TreeNode
                node.Text = "Size : " & ptrCurrentGame.TextForSize(ptrSelectedChit.Size)
                node.ImageIndex = 2
                node.SelectedImageIndex = 2
                .Add(node)

                If Not _mapdata Is Nothing Then
                    node = New TreeNode
                    node.Text = "Terrain: " & _mapdata.TerrainNameAtCoord(New Point(ptrSelectedChit.PreciseLocation.X, ptrSelectedChit.PreciseLocation.Y))
                    node.ImageIndex = 3
                    node.SelectedImageIndex = 3
                    .Add(node)
                End If
                

                node = New TreeNode
                node.Text = "ZOC: " & ptrSelectedChit.ZOC
                node.ImageIndex = 4
                node.SelectedImageIndex = 4
                .Add(node)

            End With
        Catch ex As Exception
            HandleException(c_Module, ex)
        End Try

    End Sub

    Private Function WayLength(ByRef ch As BattlegroupChit) As String
        '// returns the waypoint length of the provided chit
        Try
            Dim text As String = "0 miles"
            Dim x As Integer
            Dim dist As Long

            Dim obj As Object
            For Each obj In ch.waypoints
                If x = 0 Then
                    dist += XYDistance(ch.Location, ch.waypoints.item(x).LOC)
                Else
                    dist += XYDistance(ch.waypoints.item(x - 1).LOC, ch.waypoints.item(x).LOC)
                End If
                x += 1
            Next

            '// now we can total up the distance and turn it to string
            Dim mi As Single = dist / m_PixelsPerOneMile
            If dist > 0 Then text = Math.Round(mi, 2) & " miles"

            Return text

        Catch ex As Exception
            HandleException("ctlSelctedChitProperties", ex)
            Return "0 miles"
        End Try
    End Function

    Private Sub ListElements(ByRef unit As UnitType, ByRef node As TreeNode)
        Try

            Dim group As ElementGroup
            Dim EleGroup As GroupableElements = unit.ChitElements

            If unit.ChitElements.Count = 0 Then Exit Sub

            For Each group In EleGroup.Groups
                Dim GroupNode As New CampaignerItemTreeNode
                GroupNode.Text = group.GroupName
                GroupNode.ItemType = CampaignerItem_cgd.ElementGroup
                GroupNode.Item = group
                GroupNode.ImageIndex = 9
                GroupNode.SelectedImageIndex = 9
                node.Nodes.Add(GroupNode)
            Next

            Dim ele As GroupableElement
            Dim opt As ElementOption

            '// first post the Non-grouped elements
            For Each ele In EleGroup
                If ele.GroupName = "<Ungrouped>" Then
                    Dim ungroupedelenode As New CampaignerItemTreeNode

                    For Each opt In ele.Options
                        Dim optNode As New TreeNode
                        optNode.Text = opt.ElementOptionTypeName & " (" & opt.ElementOptionPointCost & ")"
                        optNode.SelectedImageIndex = 11
                        optNode.ImageIndex = 11
                        ungroupedelenode.Nodes.Add(optNode)
                    Next

                    ungroupedelenode.Text = ele.Count & "x " & ele.ElementTypeName & " (" & ele.TotalCost & ")"
                    ungroupedelenode.ImageIndex = 10
                    ungroupedelenode.SelectedImageIndex = 10
                    ungroupedelenode.ItemType = CampaignerItem_cgd.Element
                    ungroupedelenode.Item = ele
                    node.Nodes.Add(ungroupedelenode)
                End If
            Next

            '// now go through all of the elements and find the group it belongs to
            For Each ele In EleGroup
                Dim nodie As TreeNode
                For Each nodie In node.Nodes
                    If ele.GroupName = nodie.Text Then
                        Dim eleNode As New CampaignerItemTreeNode

                        For Each opt In ele.Options
                            Dim optNode As New TreeNode
                            optNode.Text = opt.ElementOptionTypeName
                            optNode.SelectedImageIndex = 11
                            optNode.ImageIndex = 11
                            eleNode.Nodes.Add(optNode)
                        Next

                        eleNode.Text = ele.Count & "x " & ele.ElementTypeName & " (" & ele.TotalCost & ")"
                        eleNode.ImageIndex = 10
                        eleNode.SelectedImageIndex = 10
                        eleNode.ItemType = CampaignerItem_cgd.Element
                        eleNode.Item = ele
                        nodie.Nodes.Add(eleNode)
                    End If
                Next
            Next
        Catch ex As Exception
            HandleException("frmChitTreeHierarchy.BuildTree", ex)
        End Try
    End Sub

    Private Sub ShowRulesInRange(ByVal location As Point)
        'Dim gc As GroundChitType
        'Dim gcKey As String
        'Dim obj As ObjectiveType
        'Dim ruleKey As String
        'Dim tok As TokenType
        'Dim rulet As RuleType
        'Dim rul As Rule
        'Dim bAddRule As Boolean
        'Dim modifiedRange As Integer

        'For Each gcKey In ptrCurrentGame.AllChits.Keys
        '    gc = ptrCurrentGame.AllChits.Item(gcKey)
        '    Select Case gc.GroundChitClass
        '        Case Is = GroundChitClass_cgd.Objective
        '            If ptrSelectedChit.OwningFaction = gc.OwningFaction Then
        '                obj = gc
        '                For Each rul In gc.GCRules
        '                    rulet = ptrCurrentGame.RuleTypes_g.Item(CampaignerGameData.CDGKEY_RULETYPE & rul.ruleTypeID)

        '                    bAddRule = False

        '                    modifiedRange = (rulet.BasicRange * m_PixelsPerOneMile) / 2

        '                    If XYDistance(obj.Location.X, location.X, obj.Location.Y, location.Y) <= modifiedRange Then
        '                        bAddRule = True
        '                    Else
        '                        bAddRule = False
        '                    End If

        '                    ' add this rule
        '                    If bAddRule = True Then
        '                        Dim nodString As String
        '                        Select Case rulet.AppliesDuring
        '                            Case RuleApplies_cgd.Combat : nodString = "[Combat] "
        '                            Case RuleApplies_cgd.Constant : nodString = "[Always] "
        '                            Case RuleApplies_cgd.NonCombat : nodString = "[Non-Combat] "
        '                        End Select
        '                        Dim nod As New TreeNode(nodString & rulet.RuleName)
        '                        tvwProperties.Nodes.Add(nod)
        '                    End If

        '                Next
        '            End If
        '        Case Is = GroundChitClass_cgd.Token
        '            ' TODO: handle token rule
        '    End Select
        'Next

    End Sub

    Private Sub SetUnitOrder(ByVal newOrder As String)
        If ptrSelectedChit.UnitType <> GroundChitClass_cgd.Battlegroup Then Exit Sub
        Dim unit As BattlegroupChit = DirectCast(ptrSelectedChit, BattlegroupChit)

        unit.order = newOrder

    End Sub

    Private Sub cboOrders_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cboOrders.SelectedIndexChanged
        If ptrSelectedChit Is Nothing Then Exit Sub

        If ptrSelectedChit.UnitType = GroundChitClass_cgd.Battlegroup Then
            DirectCast(ptrSelectedChit, BattlegroupChit).order = cboOrders.Text

            '// update the first waypoint if it exists
            If Not firstWaypointNode Is Nothing Then
                Dim swap As SmartWaypoint = firstWaypointNode.Item
                swap.OrderText = cboOrders.Text
                firstWaypointNode.Text = "[1] " & WaypointText(swap)
            End If
        End If

    End Sub

    Private Sub mnuHold_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles mnuHold.Click
        Try
            Dim swap As SmartWaypoint = DirectCast(tvwProperties.SelectedNode, CampaignerItemTreeNode).Item

            swap.OrderText = "Hold"
            tvwProperties.SelectedNode.Text = "[" & tvwProperties.SelectedNode.Tag & "] " & WaypointText(DirectCast(tvwProperties.SelectedNode, CampaignerItemTreeNode).Item)
            Dim bg As BattlegroupChit = ptrSelectedChit
            bg.order = "Hold"

            If tvwProperties.SelectedNode.Equals(firstWaypointNode) Then
                '// change the text in the combo box
                cboOrders.Text = "Hold"
            End If

        Catch ex As Exception
            HandleException("ctlSelectedChitProperties.menuclick", ex)
        End Try
    End Sub

    Private Sub mnuDigin_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles mnuDigin.Click
        Try
            Dim swap As SmartWaypoint = DirectCast(tvwProperties.SelectedNode, CampaignerItemTreeNode).Item
            swap.OrderText = "Dig-in"
            tvwProperties.SelectedNode.Text = "[" & tvwProperties.SelectedNode.Tag & "] " & WaypointText(DirectCast(tvwProperties.SelectedNode, CampaignerItemTreeNode).Item)
            Dim bg As BattlegroupChit = ptrSelectedChit
            bg.order = "Dig-in"

            If tvwProperties.SelectedNode.Equals(firstWaypointNode) Then
                cboOrders.Text = "Dig-in"
            End If

        Catch ex As Exception
            HandleException("ctlSelectedChitProperties.menuclick", ex)
        End Try
    End Sub

    Private Sub mnuEngage_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles mnuEngage.Click
        Try
            Dim swap As SmartWaypoint = DirectCast(tvwProperties.SelectedNode, CampaignerItemTreeNode).Item
            swap.OrderText = "Engage"
            tvwProperties.SelectedNode.Text = "[" & tvwProperties.SelectedNode.Tag & "] " & WaypointText(DirectCast(tvwProperties.SelectedNode, CampaignerItemTreeNode).Item)
            Dim bg As BattlegroupChit = ptrSelectedChit
            bg.order = "Engage"

            If tvwProperties.SelectedNode.Equals(firstWaypointNode) Then
                cboOrders.Text = "Engage"
            End If

        Catch ex As Exception
            HandleException("ctlSelectedChitProperties.menuclick", ex)
        End Try
    End Sub

    Private Sub mnuWithdraw_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles mnuWithdraw.Click
        Try
            Dim swap As SmartWaypoint = DirectCast(tvwProperties.SelectedNode, CampaignerItemTreeNode).Item
            swap.OrderText = "Withdraw"
            tvwProperties.SelectedNode.Text = "[" & tvwProperties.SelectedNode.Tag & "] " & WaypointText(DirectCast(tvwProperties.SelectedNode, CampaignerItemTreeNode).Item)
            Dim bg As BattlegroupChit = ptrSelectedChit
            bg.order = "Withdraw"
            If tvwProperties.SelectedNode.Equals(firstWaypointNode) Then
                cboOrders.Text = "Withdraw"
            End If
        Catch ex As Exception
            HandleException("ctlSelectedChitProperties.menuclick", ex)
        End Try
    End Sub

    Private Sub mnu100speed_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles mnu100speed.Click
        Try
            Dim citn As CampaignerItemTreeNode = DirectCast(tvwProperties.SelectedNode, CampaignerItemTreeNode)
            Dim bg As BattlegroupChit = ptrSelectedChit
            Dim speed As Single = bg.movementSpeed

            'speed = DirectCast(citn.Item, SmartWaypoint).Speed
            DirectCast(citn.Item, SmartWaypoint).Speed = speed
            tvwProperties.SelectedNode.Text = WaypointText(DirectCast(tvwProperties.SelectedNode, CampaignerItemTreeNode).Item)


        Catch ex As Exception
            HandleException("ctlSelectedChitProperties.Speedmenuclick", ex)
        End Try
    End Sub

    Private Sub mnu25speed_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles mnu25speed.Click
        Try
            Dim citn As CampaignerItemTreeNode = DirectCast(tvwProperties.SelectedNode, CampaignerItemTreeNode)
            Dim bg As BattlegroupChit = ptrSelectedChit
            Dim speed As Single = bg.movementSpeed * 0.25

            'speed = DirectCast(citn.Item, SmartWaypoint).Speed * 0.25
            DirectCast(citn.Item, SmartWaypoint).Speed = speed
            tvwProperties.SelectedNode.Text = WaypointText(DirectCast(tvwProperties.SelectedNode, CampaignerItemTreeNode).Item)


        Catch ex As Exception
            HandleException("ctlSelectedChitProperties.Speedmenuclick", ex)
        End Try
    End Sub

    Private Sub mnu50speed_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles mnu50speed.Click
        Try
            Dim citn As CampaignerItemTreeNode = DirectCast(tvwProperties.SelectedNode, CampaignerItemTreeNode)
            Dim bg As BattlegroupChit = ptrSelectedChit
            Dim speed As Single = bg.movementSpeed * 0.5

            ' speed = DirectCast(citn.Item, SmartWaypoint).Speed * 0.5
            DirectCast(citn.Item, SmartWaypoint).Speed = speed
            tvwProperties.SelectedNode.Text = WaypointText(DirectCast(tvwProperties.SelectedNode, CampaignerItemTreeNode).Item)


        Catch ex As Exception
            HandleException("ctlSelectedChitProperties.Speedmenuclick", ex)
        End Try
    End Sub

    Private Sub mnu75speed_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles mnu75speed.Click
        Try
            Dim citn As CampaignerItemTreeNode = DirectCast(tvwProperties.SelectedNode, CampaignerItemTreeNode)
            Dim bg As BattlegroupChit = ptrSelectedChit
            Dim speed As Single = bg.movementSpeed * 0.75

            'speed = DirectCast(citn.Item, SmartWaypoint).Speed * 0.75
            DirectCast(citn.Item, SmartWaypoint).Speed = speed
            tvwProperties.SelectedNode.Text = WaypointText(DirectCast(tvwProperties.SelectedNode, CampaignerItemTreeNode).Item)


        Catch ex As Exception
            HandleException("ctlSelectedChitProperties.Speedmenuclick", ex)
        End Try
    End Sub

    Private Sub mnuEnterspeed_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles mnuEnterspeed.Click
        Try

            Dim citn As CampaignerItemTreeNode = DirectCast(tvwProperties.SelectedNode, CampaignerItemTreeNode)
            Dim bg As BattlegroupChit = ptrSelectedChit
            Dim speed As Single = bg.movementSpeed


            Dim fenter As New frmBasicEntry("Enter new speed for this Battlegroup.", "[0-9]*")
            fenter.ShowDialog()
            If IsNumeric(fenter.Data) Then
                speed = CSng(fenter.Data)

                If speed > bg.movementSpeed Then
                    '// yell
                    MessageBox.Show("You must select a speed less than or equal to the maximum speed of the Battlegroup.", "Enter Speed", MessageBoxButtons.OK)

                Else
                    DirectCast(citn.Item, SmartWaypoint).Speed = speed

                    tvwProperties.SelectedNode.Text = WaypointText(DirectCast(tvwProperties.SelectedNode, CampaignerItemTreeNode).Item)

                End If

            Else
                MessageBox.Show("Please enter a valid speed between 0 and the maximum speed of the battlegroup", "Enter Speed", MessageBoxButtons.OK)

            End If


        Catch ex As Exception
            HandleException("ctlSelectedChitProperties.Speedmenuclick", ex)
        End Try
    End Sub

    Private Sub mnuRemoveWaypoint_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles mnuRemoveWaypoint.Click
        Try
            Dim citn As CampaignerItemTreeNode = DirectCast(tvwProperties.SelectedNode, CampaignerItemTreeNode)

            Dim bg As BattlegroupChit = ptrSelectedChit
            bg.waypoints.remove(citn.Item)
            tvwProperties.Nodes.Remove(tvwProperties.SelectedNode)

            '// call for a redraw
            RaiseEvent RedrawRequest()

        Catch ex As Exception
            HandleException("mnuRemoveWaypoint", ex)
        End Try
    End Sub

    Private Sub mnuRemoveAllWaypoints_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles mnuRemoveAllWaypoints.Click
        Try

            Dim bg As BattlegroupChit = ptrSelectedChit
            bg.waypoints.Clear()
            tvwProperties.SelectedNode.Parent.Nodes.Clear()
            ShowSelectedChitProperties(bg, ptrCurrentGame)

            '// call for a redraw
            RaiseEvent RedrawRequest()

        Catch ex As Exception
            HandleException("ctlSelectedChitProperties.menuclick", ex)
        End Try
    End Sub

    Private Sub pnlSecondary_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles pnlSecondary.Paint
        e.Graphics.DrawImage(My.Resources.selectedchitleftCap, New Point(0, 0))
    End Sub

    Private Sub lblStatsHeader_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles lblStatsHeader.Paint, lblOrders.Paint, lblChitDetails.Paint
        e.Graphics.DrawImage(My.Resources.subPropertyLeftCap, New Point(0, 0))

    End Sub

    Private Sub lblStatsHeader_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lblStatsHeader.Click

    End Sub

    Private Sub tvwProperties_NodeMouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.TreeNodeMouseClickEventArgs) Handles tvwProperties.NodeMouseClick
        Try
            If TypeOf e.Node Is CampaignerItemTreeNode Then
                '// find out what kind of item it is, and make the action
                Dim citn As CampaignerItemTreeNode = e.Node

                Select Case citn.ItemType
                    Case CampaignerItem_cgd.Unit
                        '// we can put the text of this unit in the description area. :)
                        lblDescription.Text = DirectCast(citn.Item, ChitUnitTypeMember).ptrUnitType.Description

                    Case CampaignerItem_cgd.Resource
                        lblDescription.Text = DirectCast(citn.Item, ResourcePoolItem).resourceTypeptr.ResourceDescription

                        If e.Button = Windows.Forms.MouseButtons.Right Then
                            '// put the resource pointer into the tag of the menu item
                            mnuConsumeResource.Tag = DirectCast(citn.Item, ResourcePoolItem)
                            mnuResourcePopup.Show(tvwProperties, e.Location)
                        End If

                    Case CampaignerItem_cgd.Rule
                        lblDescription.Text = DirectCast(citn.Item, Rule).ptrRule.RuleText
                        RaiseEvent ShowRuleRange(citn.Item)

                    Case CampaignerItem_cgd.waypoint
                        If e.Button <> Windows.Forms.MouseButtons.Right Then Exit Sub

                        mnuWaypointPopup.Show(sender, e.X, e.Y)
                        '// if we delete the waypoint, there is nothing
                        If Not e.Node Is Nothing Then
                            '// uh... not sure wuz goin on
                        End If
                    Case CampaignerItem_cgd.Indicator
                        Dim iin As IIndicatorEntry = DirectCast(e.Node, CampaignerItemTreeNode).Item
                        CreateIndicatorPopup(iin, e)

                End Select
            End If

        Catch ex As Exception
            HandleException(c_Module, ex)
        End Try
    End Sub

    Private Sub CreateIndicatorPopup(ByRef iin As IIndicatorEntry, ByVal e As System.Windows.Forms.TreeNodeMouseClickEventArgs)
        Try
            '// the indicator type determines the entries:
            mnuIndicatorPopup.Items.Clear()

            Select Case iin.ptrIndicator.IndicatorType
                Case IndicatorType_enum.named
                    BuildIndicatorPopupMenuOptions(iin)
                Case IndicatorType_enum.namedvalue
                    BuildIndicatorPopupMenuOptions(iin)
                Case IndicatorType_enum.value
                    Dim menuTI As New ToolStripMenuItem("Change Value")
                    AddHandler menuTI.Click, AddressOf changeIndicatorValue
                    mnuIndicatorPopup.Items.Add(menuTI)
            End Select

            mnuIndicatorPopup.Show(tvwProperties, New Point(e.X, e.Y))

        Catch ex As Exception
            HandleException(c_Module, ex)
        End Try
    End Sub

    Private Sub BuildIndicatorPopupMenuOptions(ByVal iin As IIndicatorEntry)
        Try
            If iin.ptrIndicator.IndicatorType = IndicatorType_enum.named Then
                Dim iinN As NamedIndicatorEntry = DirectCast(iin, NamedIndicatorEntry)
                For Each n As String In DirectCast(iinN.ptrIndicator, NamedIndicator).names
                    Dim mit As New ToolStripMenuItem(n)
                    mit.Tag = iin
                    AddHandler mit.Click, AddressOf changeIndicatorNameValue
                    mnuIndicatorPopup.Items.Add(mit)
                Next
            ElseIf iin.ptrIndicator.IndicatorType = IndicatorType_enum.namedvalue Then
                Dim iinNV As NamedValueIndicatorEntry = DirectCast(iin, NamedValueIndicatorEntry)
                For Each key As String In DirectCast(iinNV.ptrIndicator, NamedValueIndicator).Items.Keys

                    Dim mit As New ToolStripMenuItem(key)
                    mit.Tag = iin
                    AddHandler mit.Click, AddressOf changeIndicatorNameValue
                    mnuIndicatorPopup.Items.Add(mit)
                Next


            End If
        Catch ex As Exception
            mnuIndicatorPopup.Items.Add(ex.Message)
        End Try
    End Sub

    Private Sub changeIndicatorNameValue(ByVal sender As Object, ByVal e As System.EventArgs)
        '// this is for 'named value' and 'named' indicators
        '// the indicator entry is in the tag of the sender
        Try
            '// the treenode needs to be updated as well...
            Dim tNode As TreeNode = tvwProperties.SelectedNode
            '// change the selection
            Dim iinE As IIndicatorEntry = sender.Tag
            Select Case iinE.ptrIndicator.IndicatorType
                Case IndicatorType_enum.named
                    Dim iinN As NamedIndicatorEntry = DirectCast(iinE, NamedIndicatorEntry)
                    '// now, change the name
                    iinN.name = sender.text

                Case IndicatorType_enum.namedvalue
                    Dim iinNV As NamedValueIndicatorEntry = DirectCast(iinE, NamedValueIndicatorEntry)
                    iinNV.Name = sender.text
            End Select

            tNode.Text = iinE.displayText

            Dim log As New CampaignerLogEvent(ptrCurrentGame.selectedPlayer.PlayerName & " changed an indicator value.", ptrCurrentGame.selectedPlayer.PlayerName, ptrCurrentGame.Turn, "x to y", EventAuthorityLevel.ModeratorEvent)
            ptrCurrentGame.LogEvents.Add(log)

        Catch ex As Exception
            HandleException(c_Module, ex)
        End Try
    End Sub

    Private Sub changeIndicatorValue(ByVal sender As Object, ByVal e As System.EventArgs)
        Try
            Dim input As Single = InputBox("Enter new value.", "New Value", "0")
            Dim tnode As CampaignerItemTreeNode = tvwProperties.SelectedNode
            Dim iinV As ValueIndicatorEntry = tnode.Item

            iinV.Value = input

            tnode.Text = iinV.DisplayText

            '// make a log entry
            Dim log As New CampaignerLogEvent(ptrCurrentGame.selectedPlayer.PlayerName & " changed an indicator value.", ptrCurrentGame.selectedPlayer.PlayerName, ptrCurrentGame.Turn, "x to y", EventAuthorityLevel.ModeratorEvent)
            ptrCurrentGame.LogEvents.Add(log)

        Catch ex As Exception
            HandleException(c_Module, ex)
        End Try
    End Sub

    Private Sub mnuConsumeResource_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles mnuConsumeResource.Click
        '// this will do the consume thing... yeah
        Try
            ConsumeResource(sender.tag)
        Catch ex As Exception
            HandleException(c_Module, ex)
        End Try
    End Sub

    Private Sub ConsumeResource(ByRef ptrRes As ResourcePoolItem)
        Try
            Dim resAmount As Integer
            '// we'll simply ask how much they want to consume
            Try
                resAmount = InputBox("Enter the amount of this resource you would like to use.", "Enter Amount")
            Catch ex As Exception
                MessageBox.Show("You must enter a numeric amount.", "Invalid Amount", MessageBoxButtons.OK, MessageBoxIcon.Information)
                Exit Sub
            End Try

            '// reduce the amount
            If resAmount > ptrRes.localAmount Then resAmount = ptrRes.localAmount

            If resAmount = 0 Then Exit Sub '// if there is none

            ptrRes.localAmount -= resAmount

            '// create a log event
            ptrCurrentGame.LogEvents.Add(New CampaignerLogEvent(ptrCurrentGame.selectedPlayer.PlayerName & " consumed " & resAmount & " " & ptrRes.resourceTypeptr.ResourceName, ptrCurrentGame.selectedPlayer.PlayerName, "No Time", "<none>", EventAuthorityLevel.PublicEvent))

            '// list the sukka
            ShowSelectedChitProperties(Me.SelectedChit, Me.ptrCurrentGame)

        Catch ex As Exception
            HandleException(c_Module, ex)
        End Try
    End Sub
End Class

